package com.js.foodordersystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.js.foodordersystem.mapper.DishCategoryMapper;
import com.js.foodordersystem.entity.DishCategory;
import com.js.foodordersystem.service.DishCategoryService;
import org.springframework.stereotype.Service;
import com.js.foodordersystem.util.Result;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜品分类表(DishCategory)表服务实现类
 *
 * @author makejava
 * @since 2025-01-14 10:57:15
 */
@Service("dishCategoryService")
public class DishCategoryServiceImpl extends ServiceImpl<DishCategoryMapper, DishCategory> implements DishCategoryService {


    @Override
    public Result selectAll(DishCategory dishCategory, Integer limit, Integer page) {
        List<Map<String, Object>> list = baseMapper.selectAll(dishCategory, (page - 1) * limit, limit);
        for (Map<String, Object> map : list) {
            map.put("dishCategoryId", map.get("dishCategoryId").toString());
        }
        HashMap<String, Object> result = new HashMap<>();
        result.put("count", baseMapper.selectAllCount(dishCategory));
        result.put("data", list);
        return Result.success(result);
    }
}

